//
//  ConfigFontColorMacro.swift
//  SouWeiLaiSwift
//
//  Created by yxl on 2022/4/11.
//

import UIKit


// MARK: - 颜色设置

/// RGB颜色设置：支持(255, 255, 255)
func Color(_ r:CGFloat, _ g:CGFloat,_ b:CGFloat) -> UIColor {
    return UIColor(red: CGFloat(r) / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1.0)
}
func ColorA(_ r:CGFloat,_ g:CGFloat,_ b:CGFloat,_ a:CGFloat) -> UIColor {
    return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: a)
}
func RandomColor() -> UIColor {
    return Color(CGFloat(arc4random_uniform(255)), CGFloat(arc4random_uniform(255)), CGFloat(arc4random_uniform(255)))
}
func GrayColor(_ v:CGFloat) -> UIColor {
    return Color(v,v,v)
}

/// 十六进制颜色设置：支持#FF0000
func HexColor(_ rgbValue: String) -> UIColor? {
    return UIColor.hexColor(rgbValue, alpha: 1.0)
}
func HexColorA(_ rgbValue: String,_ a:CGFloat) -> UIColor? {
    return UIColor.hexColor(rgbValue, alpha: a)
}

// MARK: - dark mode 配置

/// 是否开启暗黑模式，iOS13之后生效，在info设置UIUserInterfaceStyle禁用则不起作用
let IsOpenDarkMode = true

/// 设置动态颜色
func DynamicColor(_ lightColor: UIColor, _ darkColor: UIColor) -> UIColor {
    return IsOpenDarkMode==false ? UIColor.dynamicColor(lightColor, lightColor) : UIColor.dynamicColor(lightColor, darkColor)
}

/// 设置动态颜色（十六进制，color：支持“#123456” ）
func DynamicHexColor(_ lightColor: String, _ darkColor: String) -> UIColor {
    return IsOpenDarkMode==false ? UIColor.dynamicHexColor(lightColor, lightColor) : UIColor.dynamicHexColor(lightColor, darkColor)
}

/// 设置动态图片
func DynamicImage(_ lightImage: String, _ darkImage: String) -> UIImage {
    return IsOpenDarkMode==false ? UIImage.dynamicImage(lightImage, lightImage) : UIImage.dynamicImage(lightImage, darkImage)
}


// MARK: - 项目颜色

/// 主题色
let BaseThemeColor = Color(65, 191, 49)
let BaseThemeGreenColor = Color(0, 190, 102)
/// 背景色
let BaseBgColor = DynamicColor(BaseBgColor_Light, BaseBgColor_Dark)
let BaseBgColor_Light = Color(255, 255, 255)
let BaseBgColor_Dark  = GrayColor(17)
/// 基础黑
let BaseBlackTextColor = HexColor("505050")!
let BaseBlackTextColor_Dark = HexColor("ffffff")!
/// 浅灰色
let BaseLightGreyTextColor = Color(119, 119, 119)
let BaseLightGreyTextColor_Dark = GrayColor(120)
/// tabbar
let BaseNonalTabbarColor = HexColor("909090")!
let BaseSelectTabbarClolr = HexColor("4A4A4A")!


/// 系统字体
let BaseWhiteColor = UIColor.white
let BaseBlackColor = UIColor.black
let BaseClearColor = UIColor.clear
let BaseRedColor = UIColor.red

/// Label颜色
let BaseLabelColor = DynamicColor(BaseBlackTextColor, BaseBlackTextColor_Dark)
/// title Label颜色
let BaseTitleLabelColor = DynamicColor(BaseBlackTextColor, BaseBlackTextColor_Dark)
/// info Label颜色
let BaseInfoLabelColor = DynamicColor(GrayColor(150), GrayColor(150))
/// Placeholder颜色
let BasePlaceholderColor = DynamicColor(GrayColor(187), GrayColor(87))
/// 分割线颜色
let BaselineColor = DynamicColor(Color(230, 230, 230), GrayColor(35))
/// 空数据文字颜色
let BaseEmptyDataTextColor = DynamicColor(BaseLightGreyTextColor, BaseLightGreyTextColor_Dark)
/// 导航条背景色，白底黑字
let BaseNavBgColor = DynamicColor(BaseWhiteColor, BaseBgColor)
/// 导航条标题颜色
let BaseNavTitleColor = DynamicColor(BaseBlackColor, BaseWhiteColor)
/// 导航条item文字颜色
let BaseNavTextColor = DynamicColor(BaseBlackColor, BaseWhiteColor)
/// 导航条背景色，主题色白字
let BaseNavBgColor2 = DynamicColor(BaseThemeColor, BaseBgColor)
/// 导航条标题颜色
let BaseNavTitleColor2 = DynamicColor(BaseWhiteColor, BaseWhiteColor)
/// TabBar背景色
let BaseTabBarBgColor = DynamicColor(BaseWhiteColor, GrayColor(29))
/// TabBar默认文字颜色
let BaseTabBarNormalTextColor = DynamicColor(BaseNonalTabbarColor, BaseNonalTabbarColor)
/// TabBar选中文字颜色
let BaseTabBarSelectTextColor = DynamicColor(BaseSelectTabbarClolr, BaseSelectTabbarClolr)
/// Cell背景颜色
let BaseCellBgColor = DynamicColor(BaseWhiteColor, GrayColor(25))
/// TextView背景颜色
let BaseTextViewBgColor = DynamicColor(GrayColor(250), GrayColor(50))
/// Btn、segment等UI组件背景颜色
let BaseBtnBgColor = DynamicColor(BaseThemeColor, GrayColor(43))
/// Toast 背景颜色
let BaseToastBgColor = DynamicColor(BaseWhiteColor, GrayColor(47))
/// Alert 背景颜色
let BaseAlertBgColor = DynamicColor(BaseWhiteColor, GrayColor(44))
/// Picker 背景颜色
let BasePickerBgColor = DynamicColor(BaseWhiteColor, GrayColor(30))
/// Pop 背景颜色
let BasePopBgColor = DynamicColor(BaseWhiteColor, GrayColor(64))
/// 白黑
let BaseWhiteByBlackColor = DynamicColor(BaseWhiteColor, BaseBlackColor)



// MARK: - 字体设置

/// 设置字体大小
func Font(_ size:CGFloat) -> UIFont {
    return UIFont.systemFont(ofSize: size)
}
/// 设置中粗字体字号
func MediumFont(_ size:CGFloat) -> UIFont {
    return UIFont(name: "PingFangSC-Medium", size: size) ?? UIFont.systemFont(ofSize: size)
}
/// 设置粗体字字号
func BoldFont(_ size:CGFloat) -> UIFont {
    return UIFont.boldSystemFont(ofSize: size)
}

/// 根据屏幕自适应字体参数 16 * FontFit
let FontFit = min(UIScreen.main.bounds.width, UIScreen.main.bounds.height) / 375


